#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
#define rep(i,l,r) for(int i=(l),i##end=(r);i<=i##end;++i)
#define per(i,r,l) for(int i=(r),i##end=(l);i>=i##end;--i)
#define int long long
#define double long double
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rbtree(way) tree<way,null_type,less<way>,rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
const int maxn=1e6+10,maxm=1e6+10,mod=998244353,inf=1e9;

int n,n1,m,m1=1e4,ans,c[maxn],t[maxn],w[maxn],tmp[maxn],id[maxn],f[maxn],t1[maxn],w1[maxn];

signed main(){
	freopen("book.in","r",stdin),freopen("book.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	rep(i,1,n) cin>>c[i];
	rep(i,1,n) cin>>t[i];
	rep(i,1,n) cin>>w[i];
	cin>>m;
	if(m>m1){
		rep(i,1,n) id[i]=i;
		sort(id+1,id+n+1,[&](int x,int y){return w[x]*t[y]<w[y]*t[x];});
		rep(i,1,n) tmp[i]=c[id[i]];
		rep(i,1,n) c[i]=tmp[i],tmp[i]=t[id[i]];
		rep(i,1,n) t[i]=tmp[i],tmp[i]=w[id[i]];
		rep(i,1,n) w[i]=tmp[i];
		// rep(i,1,n) cerr<<id[i]<<' '<<c[i]<<' '<<t[i]<<' '<<w[i]<<'\n';
		rep(i,1,n){
			if(m-m1>c[n]*t[n]) m-=c[n]*t[n],ans+=c[n]*w[n],--n;
			else c[n]-=(m-m1)/t[n],ans+=(m-m1)/t[n]*w[n],m-=(m-m1)/t[n]*t[n],i=iend;
		}
	}
	rep(i,1,n){
		int x=1;
		for(;c[i]>x;x<<=1) c[i]-=x,w1[++n1]=w[i]*x,t1[n1]=t[i]*x;
		w1[++n1]=w[i]*c[i],t1[n1]=t[i]*c[i];
	}
	// rep(i,1,n1) cerr<<t1[i]<<" "<<w1[i]<<"\n";
	rep(i,1,n1) per(j,m,t1[i]) f[j]=max(f[j],f[j-t1[i]]+w1[i]);
	rep(i,1,m) f[i]=max(f[i],f[i-1]);
	cout<<ans+f[m];
	return 0;
}